/***********************************************************************
 * Module:  FakePlateVehicleController.java
 * Author:  Administrator
 * Purpose: Defines the Class FakePlateVehicleController
 ***********************************************************************/

package ishitong.vehicleManagement.controller;

import ishitong.vehicleManagement.model.FakePlateVehicleQuery;
import ishitong.vehicleManagement.model.FakePlateVehicle;
import ishitong.common.SysCodeType;
import ishitong.common.model.SysCode;
import ishitong.commons.pagination.Pagination;
import ishitong.vehicleManagement.service.biz.FakePlateVehicleService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.ishitong.platform.common.page.Page;

/** @pdOid 35711cee-1783-43ed-ab3a-df244a2f8db8 */
@Controller
public class FakePlateVehicleController extends ishitong.common.controller.ActionController {
   /** @pdOid f3ced78b-106c-488e-b3cc-ff882ce9ad03 */
   private static final String FAK_PLA_VEH_SCH = "vehicleManagement/fakePlateVehicle/fakePlateVehicleSearch";
   /** @pdOid 72b1aa29-6f33-4e31-b27d-5cc4b98e7543 */
   private static final String FAK_PLA_VEH_SCH_LST = "vehicleManagement/fakePlateVehicle/fakePlateVehicleSearchList";
   /** @pdOid 4d9027ea-a329-4022-9acd-6156a46d93f2 */
   private static final String FAK_PLA_VEH_EDT = "vehicleManagement/fakePlateVehicle/fakePlateVehicleEdit";
   /** @pdOid 4eebe310-8da0-4cfc-afb5-d2c5d8c49cdd */
   private static final String FAK_PLA_VEH_VIW = "vehicleManagement/fakePlateVehicle/fakePlateVehicleView";
   /** @pdOid 1d94a7dd-3b63-403e-8996-d75629b41925 */
   @Autowired
   private FakePlateVehicleService fakePlateVehicleService;
   
   /** @param request
    * @exception Exception
    * @pdOid 3a3595d5-b4eb-4762-8aa0-0c4f7bdeff6b */
   @RequestMapping(value = "/showFakePlateVehicleSearch.do")
   public ModelAndView handleShowFakePlateVehicleSearch(HttpServletRequest request) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND);
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   		// 使用性质
   		List<SysCode> lstUseNature = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   
   		// 车辆分类
   		List<SysCode> lstVehicleSort = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleSort", lstVehicleSort);
   
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   		return new ModelAndView(FAK_PLA_VEH_SCH,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param fakePlateVehicleQuery 
    * @param pagination
    * @pdOid ffd60ca8-8f9f-4c4c-8dc0-833a31b5b39a */
   @RequestMapping(value = "/ajaxFakePlateVehicleSearchList.do",method = RequestMethod.POST)
   public ModelAndView handleAjaxFindFakePlateVehicleSearchList(HttpServletRequest request, FakePlateVehicleQuery fakePlateVehicleQuery, Pagination pagination) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		Page<FakePlateVehicle> page = fakePlateVehicleService.findPage(fakePlateVehicleQuery, pagination.getPageSize(), pagination.getCurrentPage());
   		model.put("page", page);
   		return new ModelAndView(FAK_PLA_VEH_SCH_LST,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param fakePlateVehicleId
    * @exception Exception
    * @pdOid 938e340c-fa1a-45a8-9e7e-d36f614d31e0 */
   @RequestMapping(value = "/ajaxShowFakePlateVehicleEdit.do",method = RequestMethod.POST)
   public ModelAndView handleAjaxShowFakePlateVehicleEdit(HttpServletRequest request, String fakePlateVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND);
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   		// 号牌颜色
   		List<SysCode> lstPlateColor = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_COLOR);
   		model.put("lstPlateColor", lstPlateColor);
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   		// 车身颜色
   		List<SysCode> lstVehicleColor = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_COLOR);
   		model.put("lstVehicleColor", lstVehicleColor);
   		// 使用性质
   		List<SysCode> lstUseNature = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   		// 车辆分类
   		List<SysCode> lstVehicleClassification = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleClassification", lstVehicleClassification);
   
   		if(!StringUtils.isEmpty(fakePlateVehicleId)){
   			FakePlateVehicle fakePlateVehicle = fakePlateVehicleService.findById(fakePlateVehicleId);
   			model.put("fakePlateVehicle", fakePlateVehicle);
   		}
   		return new ModelAndView(FAK_PLA_VEH_EDT,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param fakePlateVehicle 
    * @param response
    * @exception Exception
    * @pdOid 32b7cd8c-9ac1-45be-ab36-45155c104635 */
   @RequestMapping(value = "/ajaxSaveFakePlateVehicle.do",method = RequestMethod.POST)
   public void handleAjaxSaveFakePlateVehicle(HttpServletRequest request, FakePlateVehicle fakePlateVehicle, HttpServletResponse response) throws Exception {
   	try {
   		fakePlateVehicleService.save(fakePlateVehicle);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param fakePlateVehicleId
    * @exception Exception
    * @pdOid 1e66fc3d-f47a-4157-b5ac-b542b65c9ec0 */
   @RequestMapping(value = "/ajaxShowFakePlateVehicleView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowFakePlateVehicleView(HttpServletRequest request, String fakePlateVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   		if(!StringUtils.isEmpty(fakePlateVehicleId)){
   			FakePlateVehicle fakePlateVehicle = fakePlateVehicleService.findById(fakePlateVehicleId);
   			model.put("fakePlateVehicle", fakePlateVehicle);
   		}
   		return new ModelAndView(FAK_PLA_VEH_VIW,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param fakePlateVehicleIds 
    * @param response
    * @exception Exception
    * @pdOid 462b5a89-77b1-44f3-b760-c1adf651086c */
   @RequestMapping(value = "/ajaxDeleteFakePlateVehicleByIds.do",method = RequestMethod.POST)
   public void handleAjaxDeleteFakePlateVehicleByIds(HttpServletRequest request, String fakePlateVehicleIds, HttpServletResponse response) throws Exception {
   	try {
   		fakePlateVehicleService.delete(fakePlateVehicleIds);
   	} catch (Exception e) {
   		e.printStackTrace();
   	} 	
   }

}